{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "046d5054",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "231 ns ± 1.41 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)\n",
      "48.7 ns ± 0.874 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)\n"
     ]
    }
   ],
   "source": [
    "x = 5\n",
    "%timeit y=x**2\n",
    "%timeit y=x*x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "34b587b9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5.71 µs ± 32.8 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)\n",
      "8.91 µs ± 85.5 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)\n"
     ]
    }
   ],
   "source": [
    "import cv2 as cv\n",
    "import numpy as np\n",
    "\n",
    "img = cv.imread('../data/messi5.jpg')\n",
    "img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)\n",
    "\n",
    "%timeit z = cv.countNonZero(img)\n",
    "%timeit z = np.count_nonzero(img)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "20e014e9",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
